<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8">
    <title>教师选课情况</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/index.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/role.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/table.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/SelectCourseSystem.js"></script>
</head>
<body>
<div class="contain">
    <%@ include file="loginHead.jsp" %>
    <%@ include file="teacherNavigate.jsp" %>

    <div class="addCourse">
        <p>请输入新课程详细信息，并点击添加按钮</p>
        <div class="form">
            <form action="${pageContext.request.contextPath}/AddTeacherCourseServlet" method="post">
                <fieldset class="fieldset">
                    <tr>
                        <td>课程编号</td>
                        <td><label>
                            <input type="text" name="courseID" required>
                        </label></td>
                    </tr>
                    <br/>

                    <tr>
                        <td>课程名称</td>
                        <td><label>
                            <input type="text" name="courseName" required>
                        </label></td>
                    </tr>
                    <br/>

                    <tr>
                        <td>教师姓名</td>
                        <td><label>
                            <input type="text" name="teacher" required>
                        </label></td>
                    </tr>
                    <br/>
                    <tr>
                        <td>学　　分</td>
                        <td><label>
                            <input type="text" name="point" required placeholder="(1~6)">
                        </label></td>
                    </tr>
                    <br/>

                    <tr>
                        <td>上课时间:</td>
                        <td>
                            <br/>
                        <td>
                            第一次
                            <select name="time_1_weekday" id="time_1_weekday">
                                <option value="1">星期一</option>
                                <option value="2">星期二</option>
                                <option value="3">星期三</option>
                                <option value="4">星期四</option>
                                <option value="5">星期五</option>
                            </select>
                            <select name="time_1_timeFrame" id="time_1_timeFrame">
                                <option value="1">8:05~9:50</option>
                                <option value="2">10:15~12:00</option>
                                <option value="3">13:35~15:20</option>
                                <option value="4">15:45~17:30</option>
                                <option value="5">18:30~20:45</option>
                            </select><br/>
                    </tr>

                    <tr>
                        第二次
                        <select name="time_2_weekday" id="time_2_weekday">
                            <option value="1">星期一</option>
                            <option value="2">星期二</option>
                            <option value="3">星期三</option>
                            <option value="4">星期四</option>
                            <option value="5">星期五</option>
                        </select>
                        <select name="time_2_timeFrame" id="time_2_timeFrame">
                            <option value="1">8:05~9:50</option>
                            <option value="2">10:15~12:00</option>
                            <option value="3">13:35~15:20</option>
                            <option value="4">15:45~17:30</option>
                            <option value="5">18:30~20:45</option>
                        </select>
                    </tr>
                    <br/>

                    <tr>
                        <td>上课地点</td>
                        <td><label>
                            <input type="text" name="location" required>
                        </label></td>
                    </tr>
                    <br/>

                    <tr>
                        <td>限制人数</td>
                        <td><label>
                            <input type="text" name="limited" required>
                        </label></td>
                    </tr>
                    <br/>

                    <div class="selectBtn">
                        <button id="selectBtn">添加</button>
                    </div>
                </fieldset>
            </form>
        </div>
    </div>
</div>

<%

    if (session.getAttribute("flag") == null) {
%>

<%
} else if ((int) session.getAttribute("flag") == 1) {
%>
<script>
    alert("添加课程成功");
</script>
<%
} else if ((int) session.getAttribute("flag") == -1) {
%>
<script>
    alert("添加课程失败");
</script>

<%
    }
%>

<script type="text/javascript">

    let selectBtn = document.getElementById("selectBtn")
    let time_1_weekday = document.getElementById("time_1_weekday");
    let time_1_timeFrame = document.getElementById("time_1_timeFrame");
    let time_2_weekday = document.getElementById("time_2_weekday");
    let time_2_timeFrame = document.getElementById("time_2_timeFrame");
    selectBtn.addEventListener('click', e => {
        if (time_1_weekday.value === time_2_weekday.value && time_1_timeFrame.value === time_2_timeFrame.value) {
            alert("时间不能设置为相同时间段！");
            if (e && e.preventDefault)
                e.preventDefault();
            else
                window.event.returnValue = false;
        }
    })
</script>
</body>
</html>